const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('act_ru_identitylink', {
    id: {
      type: DataTypes.STRING(64),
      allowNull: false,
      primaryKey: true,
      field: 'ID_'
    },
    rev: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'REV_'
    },
    groupId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'GROUP_ID_'
    },
    type: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'TYPE_'
    },
    userId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'USER_ID_'
    },
    taskId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_task',
        key: 'id_'
      },
      field: 'TASK_ID_'
    },
    procInstId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'PROC_INST_ID_'
    },
    procDefId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_re_procdef',
        key: 'id_'
      },
      field: 'PROC_DEF_ID_'
    },
    scopeId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_ID_'
    },
    scopeType: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_TYPE_'
    },
    scopeDefinitionId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'SCOPE_DEFINITION_ID_'
    }
  }, {
    sequelize,
    tableName: 'act_ru_identitylink',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "ID_" },
        ]
      },
      {
        name: "ACT_IDX_IDENT_LNK_USER",
        using: "BTREE",
        fields: [
          { name: "USER_ID_" },
        ]
      },
      {
        name: "ACT_IDX_IDENT_LNK_GROUP",
        using: "BTREE",
        fields: [
          { name: "GROUP_ID_" },
        ]
      },
      {
        name: "ACT_IDX_IDENT_LNK_SCOPE",
        using: "BTREE",
        fields: [
          { name: "SCOPE_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_IDX_IDENT_LNK_SCOPE_DEF",
        using: "BTREE",
        fields: [
          { name: "SCOPE_DEFINITION_ID_" },
          { name: "SCOPE_TYPE_" },
        ]
      },
      {
        name: "ACT_IDX_ATHRZ_PROCEDEF",
        using: "BTREE",
        fields: [
          { name: "PROC_DEF_ID_" },
        ]
      },
      {
        name: "ACT_FK_TSKASS_TASK",
        using: "BTREE",
        fields: [
          { name: "TASK_ID_" },
        ]
      },
      {
        name: "ACT_FK_IDL_PROCINST",
        using: "BTREE",
        fields: [
          { name: "PROC_INST_ID_" },
        ]
      },
    ]
  });
};
